<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Insert title here</title>
<link href="/resource/css/bootstrap.css" rel="stylesheet">

<script type="text/javascript" src="/resource/js/jquery-3.4.1.js"></script>
<script type="text/javascript" src="/resource/js/bootstrap.js"></script>
<script type="text/javascript" src="/resource/js/bootstrap-treeview.js"></script>
<script type="text/javascript"> 
$(function(){
	$.get("/getBrands",function(list){
		for(var i in list){//品牌
			$("#bid").append("<option  value='"+list[i].bid+"'>"+list[i].bname+"</option>")
		}
		//让下来框回显
		$("#bid").val('${goods.brandId}')
	})
	
	
	$.get("/getProducts",function(list){
		for(var i in list){//分类
			$("#pid").append("<option  value='"+list[i].pid+"'>"+list[i].pname+"</option>")
		}
		//让下来框回显
		$("#pid").val('${goods.productId}')
	})
	
})

function update(){
	$.post("/update",$("form").serialize(),function(flag){
		if(flag){
			alert("修改成功");
			location.href="/list"
		}
	})
	
}
</script>
</head>
<body>
<div class="container">
 <form action="">
  商品id :<input type="text" name="id" value="${goods.id }" readonly="readonly"><br> 
  商品名称：<input type="text" name="goodsName" value="${goods.goodsName}"><br> 
  品牌名称： <select id="bid" name="brandId">
    <option></option>
   </select><br>
  品类名称：  <select id="pid" name="productId">
      <option></option>
   </select> <br>
 创建时间：<fmt:formatDate value="${goods.createDate }" pattern="yyyy-MM-dd HH:mm:ss"/> 
 <br>
 <button type="button" onclick="update()">修改</button>
 
 </form>
 </div>
</body>
</html>